//数码管  
 
#include <stdio.h>  
#include <string.h>  
  
int main()  
{  
    int input[5]={0};  
    int output[5]={0};  
    int number=0;  
    int end=1;  
    int flag=0;  
      
    while( end == 1 )  
    {  
        scanf("%d",&number);  
        if ( number==0 )  
        {  
            end = 0;  
            continue;  
        }  
          
        for( int i=0 ; i<5 ; i++)  
        {  
            input[i]=number%10;  
            number = number/10;  
        }  
          
        for ( int i=0 ; i<5 ; i++ )  
        {  
            if( input[i] == 0 )  
            {  
                input[i] = 125;  
            }  
            else if( input[i] == 1 )  
            {  
                input[i] = 80;  
            }  
            else if( input[i] == 2 )  
            {  
                input[i] = 55;  
            }  
            else if( input[i] == 3 )  
            {  
                input[i] = 87;  
            }  
            else if( input[i] == 4 )  
            {  
                input[i] = 90;  
            }  
            else if( input[i] == 5 )  
            {  
                input[i] = 79;  
            }  
            else if( input[i] == 6 )  
            {  
                input[i] = 111;  
            }  
            else if( input[i] == 7 )  
            {  
                input[i] = 84;  
            }  
            else if( input[i] == 8 )  
            {  
                input[i] = 127;  
            }  
            else if( input[i] == 9 )  
            {  
                input[i] = 95;  
            }  
        }  
          
        for( int i=4 ; i>=0 ; i--)  
        {  
            if( i>=1 )  
            {  
                printf("%X ",input[i]);  
            }  
            else if ( i==0 )  
            {  
                printf("%X\n",input[i]);  
            }  
        }  
    }  
    return 0;  
}  